package dao

import (
	"gorm.io/gorm"
	"user_manger_go/entity"
)

type UserDao struct {
	db *gorm.DB
}

func NewDao(db *gorm.DB) UserDao {
	return UserDao{
		db: db,
	}
}

func (userDao *UserDao) GetUsers() []entity.User {
	users := make([]entity.User, 0)
	userDao.db.Find(&users)
	return users
}

func (userDao *UserDao) InsertUser(user entity.User) entity.User {
	userDao.db.Create(&user)
	return user
}
